package com.cykj.service.Impl;

import com.cykj.dto.ResponseDto;
import com.cykj.mapper.ConsultingRecordMapper;
import com.cykj.pojo.PsConsultingRecord;
import com.cykj.service.ConsultantService;
import com.cykj.service.ConsultingRecordService;
import com.cykj.vo.ConsultingRecordVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: Psychology
 * @BelongsPackage: com.cykj.service.Impl
 * @Author: 小林
 * @CreateTime: 2025-02-16 21:42
 * @Description: 评估表
 * @Version: 1.0
 */
@Service
public class ConsultingRecordServiceImpl implements ConsultingRecordService {

    @Autowired
    private ConsultingRecordMapper consultingRecordMapper;

    /**
     * 插入记录
     * @param vo
     * @return
     */
    @Override
    public ResponseDto addRecord(ConsultingRecordVo vo) {
        int i = consultingRecordMapper.addRecord(vo);
        if (i > 0) {
            return ResponseDto.success("插入成功");
        }
        return ResponseDto.error("插入失败");
    }

    /**
     * 获取全部
     * @param vo
     * @return
     */
    @Override
    public ResponseDto getAll(ConsultingRecordVo vo) {
        PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
        List<PsConsultingRecord> all = consultingRecordMapper.getAll(vo);
        PageInfo<PsConsultingRecord> pageInfo = new PageInfo<>(all);
        return all != null ? ResponseDto.success(pageInfo) : ResponseDto.error("查询失败！");
    }
}

